package Messages;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;

import com.mysql.jdbc.ResultSet;

import Server.SQLConnection;

import ocsf.server.ConnectionToClient;
/**
 * This class implements the delete Lintel from DB
 *   @author Shlomit Yosfan
 * @author Nofar Sutliman
 */
public class MessageUpdateLintel {
	
	private ConnectionToClient client ;
	private String[] str; 
/**
 * constructor of this class 
 * @param str
 * @param client
 */
	public MessageUpdateLintel(String[] str, ConnectionToClient client) {
		this.client= client ;
		this.str= str; 	
	}
	/**
	 * This method delete Lintel from the DB 
	 * @throws SQLException
	 * @throws IOException
	 */
	public void UpdateLintel() throws SQLException, IOException{
		SQLConnection sc = new SQLConnection();

		java.sql.PreparedStatement ps=sc.getConnection().prepareStatement("Update DB.lintel SET LintelMeasurmenet=?,Quantity=?,MinInventory=?,MaxInventory=?,SuppID=? WHERE LintelID=?");

		ps.setString(1, str[2]);
		ps.setString(2, str[3]);
		ps.setString(3, str[4]);
		ps.setString(4, str[5]);
		ps.setString(5, str[6]);
		ps.setString(6, str[1]);
		
		ps.executeUpdate();
		client.sendToClient("LintelUpdated");
		
		ps.close();

	}
}

